/*
 * Copyright 2007 Yegor Jbanov
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.spicesoft.clientobjects.core;

import java.lang.reflect.Method;

public class PropertyMetadata {

  private String propertyName;

  private Method getterMethod;

  private Method setterMethod;

  private Method indexedGetterMethod;

  private Method indexedSetterMethod;

  private boolean enhanced;

  private boolean indexed;

  private Class<?> componentType;

  private boolean collection;

  public Class<?> getComponentType() {
    return componentType;
  }

  public void setComponentType(Class<?> componentType) {
    this.componentType = componentType;
  }

  public Method getGetterMethod() {
    return getterMethod;
  }

  public void setGetterMethod(Method getterMethod) {
    this.getterMethod = getterMethod;
  }

  public Method getIndexedGetterMethod() {
    return indexedGetterMethod;
  }

  public void setIndexedGetterMethod(Method indexedGetterMethod) {
    this.indexedGetterMethod = indexedGetterMethod;
  }

  public Method getIndexedSetterMethod() {
    return indexedSetterMethod;
  }

  public void setIndexedSetterMethod(Method indexedSetterMethod) {
    this.indexedSetterMethod = indexedSetterMethod;
  }

  public String getPropertyName() {
    return propertyName;
  }

  public void setPropertyName(String propertyName) {
    this.propertyName = propertyName;
  }

  public Method getSetterMethod() {
    return setterMethod;
  }

  public void setSetterMethod(Method setterMethod) {
    this.setterMethod = setterMethod;
  }

  public boolean isEnhanced() {
    return enhanced;
  }

  public void setEnhanced(boolean enhanced) {
    this.enhanced = enhanced;
  }

  public boolean isIndexed() {
    return indexed;
  }

  public void setIndexed(boolean indexed) {
    this.indexed = indexed;
  }

  @Override
  public boolean equals(Object o) {
    if (o instanceof PropertyMetadata) {
      if (this.propertyName.equals(((PropertyMetadata) o).getPropertyName())) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }

  @Override
  public int hashCode() {
    return this.propertyName.hashCode();
  }

  public void setCollection(boolean isCollection) {
    this.collection = isCollection;
  }
  
  public boolean isCollection() {
    return collection;
  }

}
